# Contributor: Dominique Martinet <dominique.martinet@atmark-techno.com>
# Maintainer: Dominique Martinet <dominique.martinet@atmark-techno.com>
pkgname=pahole
pkgver=1.23
pkgrel=0
pkgdesc="dwarf manipulation utilities"
url="https://git.kernel.org/pub/scm/devel/pahole/pahole.git"
arch="all"
license="GPL-2.0-only"
options="!check" # no test
makedepends="cmake elfutils-dev libdwarf-dev zlib-dev libbpf-dev
	linux-headers musl-obstack-dev argp-standalone samurai"
subpackages="$pkgname-doc"
source="https://git.kernel.org/pub/scm/devel/pahole/pahole.git/snapshot/pahole-v$pkgver.tar.gz
0001-libbpf-Update-libbpf-to-the-latest-git-HEAD.patch"
builddir="$srcdir/$pkgname-v$pkgver"

build() {
	# use libbpf installed uapi headers as we need something
	# newer than linux-headers provides
	export CFLAGS="$CFLAGS -I/usr/include/bpf/uapi"

	cmake -B build -G Ninja . \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=None \
		-D__LIB=lib \
		-DCMAKE_MODULE_PATH=/usr/lib/cmake \
		-DLIBBPF_EMBEDDED=OFF
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --build build --target install
}

sha512sums="
72c9612e00ab4631e1f8a3d461d909e9a99579744b2e5c80e5252393e9a03f81b65a68c2aab10995b5bb674810532fbad74a191f0604662a66121cf2b171f132  pahole-v1.23.tar.gz
9cd1e4efe6b97480e3bd73152bbbbb8d9d3a400b3d227e1988755694a8cc74b3aba9ed86e074d80cd61637bd3ee2ab2a08aa84cade31908f29462651f53842a1  0001-libbpf-Update-libbpf-to-the-latest-git-HEAD.patch
"
